package com.anosine.gpsl.android.ui.activity;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.anosine.gpsl.android.R;
import com.anosine.gpsl.android.entity.Login;
import com.anosine.gpsl.android.entity.ModifyPwdInfo;
import com.anosine.gpsl.android.presenter.BasePresenterActivity;
import com.anosine.gpsl.android.presenter.FeedBackPresenter;
import com.anosine.gpsl.android.presenter.RegAgreementPresenter;
import com.anosine.gpsl.android.ui.FeedBackView;
import com.anosine.gpsl.android.ui.RegAgreementView;
import com.anosine.gpsl.android.util.ToastHelper;
import com.anosine.gpsl.android.util.UserInfoProxy;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.lidroid.xutils.view.annotation.event.OnClick;
/**
 * @Title: FeedBackActivity
 * @Package com.anosine.gpsl.android.ui.activity
 * @Description: 
 * @author: sunny
 * @date: 2015-12-1
 * @version V1.0
 */
public class FeedBackActivity extends BasePresenterActivity implements
FeedBackView {
	@ViewInject(R.id.content_tv_title)
	TextView title;
	@ViewInject(R.id.et_remark)
	EditText remark;
	/**
	 * @Title: BackOnClick(View v)
	 * @Description: 返回按钮的点击事件，点击关闭当前activity
	 * @param: View v
	 * @return: 无
	 * @throws
	 */
	@OnClick(R.id.button_left)
	private void BackOnClick(View v) {
		finish();
	}
	@ViewInject(R.id.btn_right)
	Button submit;
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_feedback_layout);
		ViewUtils.inject(this);
		title.setText("意见反馈");
		submit.setText("提  交");
		submit.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// 启动MVP
				initActivityOfFeedBack();
			}
		});
		

	}
	private void initActivityOfFeedBack() {
		// 将合成的URL传给服务器
		FeedBackPresenter presenter = new FeedBackPresenter(this);
		Login userInfo = UserInfoProxy.getInstance().getLoginInfo();
		presenter.loadFeedBack(userInfo.userMd5,"",remark.getText().toString());
	}
	@Override
	public void setFeedBack(ModifyPwdInfo t) {
		if("msg_submit_true".equals(t.message)){
			ToastHelper.toast("提交意见反馈成功！");
			finish();
		}else if("msg_fail".equals(t.message)){
			ToastHelper.toast("参数错误！");
		}else if("msg_submit_false".equals(t.message)){
			ToastHelper.toast("提交意见反馈失败！");
		}
		
	}

}
